package com.wa.annotations.lifecycle;

import lombok.AllArgsConstructor;
import lombok.Data;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;

/**
 * 需要添加Component才会注入到spring中
 */
@Data
@AllArgsConstructor
@Component
public class LifeCyclePostConstructPreDestroy {
    @PostConstruct
    public void postConstruct() {
        System.out.println("LifeCyclePostConstructPreDestroy PostConstruct注解");
    }

    @PreDestroy
    public void destroy() {
        System.out.println("LifeCyclePostConstructPreDestroy preDestroy注解");
    }
}


